<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'edit';
$return=array();
if($_RQ['op']=='edit'){
	$item=$this->plugin_setting('setting');
	$plugins = $this->plugins();
	$bankuai1 =array(
		array('title'=>'美食/外卖','img'=>'../core/resource/images/diy/default/icon-1.png','action'=>'jy_dish/index/'),
		array('title'=>'酒店住宿','img'=>'../core/resource/images/diy/default/icon-2.png','action'=>'jy_jd/index/'),
		array('title'=>'休闲娱乐','img'=>'../core/resource/images/diy/default/icon-3.png','action'=>'jy_gohome/index/'),
		array('title'=>'周边商户','img'=>'../core/resource/images/diy/default/icon-4.png','action'=>'jy_cmso2o/index/'),
	);
	$item['bankuai1'] =  !empty($item['bankuai1']) ? $item['bankuai1'] : $bankuai1;
	$item['bankuai2'] =  !empty($item['bankuai2']) ? $item['bankuai2'] : $plugins[0]['list'];
	$footernav = array(
			array('title'=>'首页','icon'=>'icon-shouye','color'=>'#cc99ff','action'=>'jy_cms/index/','image'=>'../addons/jy_cms/resource/images/jy_cmsarticle.png'),
			array('title'=>'附近','icon'=>'icon-map','color'=>'#66cc99','action'=>'jy_cms/nearlist/','image'=>'../addons/jy_cms/resource/images/jy_fenleimsg.png'),
			array('title'=>'发现','icon'=>'icon-browse','color'=>'#ff9933','action'=>'jy_cms/foundlist/','image'=>'../addons/jy_cms/resource/images/jy_fenleimsg.png'),
			array('title'=>'订单','icon'=>'icon-manageorder','color'=>'#66cc66','action'=>'jy_cms/order/','image'=>'../addons/jy_cms/resource/images/jy_fenleimsg.png'),
			array('title'=>'我的','icon'=>'icon-wo1','color'=>'#FF83FA','action'=>'jy_cms/myhome/','image'=>'../addons/jy_cms/resource/images/jy_fenleimsg.png'),
	);
	$item['footernav'] = !empty($item['footernav']) ? $item['footernav'] : $footernav;
    $return['item']=$item;
	$return['item']['plugins']=$return['item']['plugins']?$return['item']['plugins']:$plugins[1]['list'];
	$return['status']=array('1'=>'开启','0'=>'关闭');
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'desc'=>'设置',
		'edit_tab'=>true,
		'edits'=>array(
				array(
					'title'=>'基本信息',
					'list'=>array(
						array('type'=>'string','title'=>'网站名称','name'=>'title'),
						array('type'=>'image','title'=>'网站LOGO','name'=>'logo'),
						array('type'=>'switch','title'=>'关闭多区域?','name'=>'no_pcd'),
					)
				),
				array(
					'title'=>'幻灯片',
					'list'=>array(
						array('type'=>'array','name'=>'hdps','add_tip'=>'添加一个幻灯片',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'图片'),	
									array('type'=>'string','name'=>'url','title'=>'地址'),
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'图片'),
									array('type'=>'link','from'=>'action','name'=>'url','title'=>'地址'),
								)
						),
					)
				),
				array(
							'title'=>'板块导航1',
							'list'=>array(
									array('type'=>'array','name'=>'bankuai1','add_tip'=>'添加一个板块导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'image','name'=>'img','title'=>'导航图片'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),
										//array('type'=>'string','name'=>'pageurl','title'=>'小程序页面'),
										array('type'=>'radio','name'=>'is_close','title'=>'是否关闭','options'=>'is_closes'),											
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'image','name'=>'img','title'=>'导航图片'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
										//array('type'=>'choose','op'=>'wxappplugins','name'=>'pageurl','title'=>'小程序页面'),	
										array('type'=>'switch','name'=>'is_close','title'=>'是否关闭'),
									)
								),
							)
				),
				array(
							'title'=>'板块导航2',
							'list'=>array(
									array('type'=>'array','name'=>'bankuai2','add_tip'=>'添加一个板块导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','title'=>'导航icon'),
										array('type'=>'color','name'=>'color','title'=>'导航颜色'),
										array('type'=>'string','name'=>'action','from'=>'action','title'=>'导航链接'),
										//array('type'=>'string','name'=>'pageurl','title'=>'小程序页面'),
										array('type'=>'radio','name'=>'is_install','title'=>'是否关闭','options'=>'is_installs'),								
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','title'=>'导航icon'),
										array('type'=>'color','name'=>'color','title'=>'导航颜色'),										
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
										//array('type'=>'choose','op'=>'wxappplugins','name'=>'pageurl','title'=>'小程序页面'),
										array('type'=>'switch','name'=>'is_install','title'=>'是否关闭'),
									)
								),
							)
				),
				array(
							'title'=>'底部导航',
							'list'=>array(
								array('type'=>'array','name'=>'footernav','add_tip'=>'添加一个底部导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),	
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),										
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
							)
				),
				array(
					'title'=>'分享设置',
					'list'=>array(
						array('type'=>'string','title'=>'分享标题','name'=>'share_title'),
						array('type'=>'image','title'=>'分享图片','name'=>'share_image'),
						array('type'=>'text','title'=>'分享描述','name'=>'share_desc'),
					)
				),
				array(
					'title'=>'首页数据',
					'list'=>array(
						array('name'=>'shopgroup_id','title'=>'商品绑定分类','type'=>'select','options'=>'shopgroups','help'=>'只能绑定一级分类，绑定一级分类下面所有商品！'),
					)
				),
				array(
				'title'=>'辅助应用',
					'list'=>array(
									array('type'=>'array','name'=>'plugins','add_tip'=>'添加一个辅助应用',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'应用名称'),
										array('type'=>'string','name'=>'desc','title'=>'应用描述'),
										array('type'=>'icon','name'=>'icon','title'=>'应用图标'),
										array('type'=>'string','name'=>'name','title'=>'应用标识'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'应用名称'),
										array('type'=>'choose','op'=>'chooseplugins','name'=>'name','title'=>'应用标识','choose_title'=>'选择应用'),
										array('type'=>'icon','name'=>'icon','title'=>'应用图标'),							
										array('type'=>'string','name'=>'desc','title'=>'应用描述'),
									)
								),
					)
				),
			)
	);
	$return['htmls']=$htmls;
	$install = check_permission('jy_weishop');
	if($install){
		$return['shopgroups']=pdo_getall('jy_weishop_goods_group',array('uniacid'=>$_SESSION['uniacid'],'parentid'=>0),array('id','title'));		
	}else{
		exi('未安装电商客插件,请联系管理员','error');
	}
	$return['is_installs']=array('1'=>'显示','0'=>'关闭');
	$return['is_closes']=array('1'=>'关闭','0'=>'显示');
	set_html('framess',$this->menu());
	exi($return);
}
if($_RQ['op']=='post'){
		$postdata=get_postdata();
		$item=$this->plugin_setting('setting',$postdata);
		exi('设置成功');
}
if($_RQ['op']=='wxappplugins'){
	$list = $this->plugins();
	$plugins = array();
	foreach($list as &$item){
		foreach($item['list'] as &$row){
			$plugins[] = $row;
		}
	}
	$return['list']=$plugins;
	$return['htmls']=array(
		'type'=>'list',
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'名称','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'name','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	exi($return);
}
if($_RQ['op']=='chooseplugins'){
	$list = pdo_getall('core_plugins',array('hide'=>0),array('id','style','name','title','image','description'),'id');
	if($list){
		foreach($list as $k=>&$item){
			if(!check_permission($item['name'])){
				unset($list[$k]);
			}else{
				$item['plugininfo'] = array('name'=>$item['name'],'title'=>$item['title'],'description'=>$item['description']);
			}
			
		}
	}
	$return['list']=$list;
	$return['htmls']=array(
		'type'=>'list',
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'名称','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'name','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	exi($return);
}
?>